Imports Clo = Enhancements.Core.Logging
Imports Fun = Enhancements.Basic.Expressions.Functions
Imports Ref = System.Reflection
Imports Sys = System

Namespace Enhancements.Basic.Expressions
    ''' <summary>The exception that is thrown when a variable's type is not valid.</summary>
    ''' <remarks>The InnerException property holds the exception that leads to the throwing of these exceptions.</remarks>
    <Serializable(), DebuggerStepThrough()> _
    Public NotInheritable Class CompilerExpressionVariableTypeIsValidNotException
        Inherits CompilerException

        Private Sub New(ByVal _expression As System.String, ByVal _variable As Variable, ByVal _type As Sys.Type, ByVal _innerException As Sys.Exception)
            MyBase.New(_innerException)
            Expression = _expression
            Variable = _variable
            Type = _type
        End Sub

        Private __Expression As System.String = Nothing
        ''' <summary>Gets the expression that caused this exception.</summary>
        Public Property Expression() As System.String
            Get
                Return __Expression
            End Get
            Private Set(ByVal _value As System.String)
                __Expression = _value
            End Set
        End Property

        Private __Variable As Variable = Nothing
        ''' <summary>Gets the variable that caused this exception.</summary>
        Public Property Variable() As Variable
            Get
                Return __Variable
            End Get
            Private Set(ByVal _value As Variable)
                __Variable = _value
            End Set
        End Property

        Private __Type As System.Type = Nothing
        ''' <summary>Gets the type that caused this exception.</summary>
        Public Property Type() As System.Type
            Get
                Return __Type
            End Get
            Private Set(ByVal _value As System.Type)
                __Type = _value
            End Set
        End Property

        ''' <summary>Throws an exception.</summary>
        ''' <param name="_expression">Expression that is causing the exception.</param>
        ''' <param name="_variable">Variable that is causing the exception.</param>
        ''' <param name="_type">Type that is causing the exception.</param>
        ''' <param name="_innerException">Exception that led to the throwing of this exception.</param>
        ''' <exception cref="CompilerExpressionVariableTypeIsValidNotException"> </exception>
        Friend Shared Sub ___Throw(ByVal _expression As System.String, ByVal _variable As Variable, ByVal _type As Sys.Type, ByVal _innerException As Sys.Exception)
            Dim _exception As CompilerExpressionVariableTypeIsValidNotException = New CompilerExpressionVariableTypeIsValidNotException(_expression, _variable, _type, _innerException)

            Throw _exception
        End Sub

    End Class
End Namespace
